/// <reference path="./Describe/GlobalExtentions.d.ts" />

export class GlobalExtentions {

    static Create() {

        String.prototype.IsNullOrEmpty = function (): boolean {
            return this === undefined || this === null || this.trim().length === 0;
        };

        String.prototype.GetHashCode = function (): number {
            let hashCode = 0;
            for (let i = 0; i < this.length; i++) {
                const charCode = this.charCodeAt(i);
                // 使用位运算符对哈希码进行计算
                hashCode = ((hashCode << 5) - hashCode) + charCode;
                hashCode |= 0; // 确保结果是一个32位有符号整数
            }
            return hashCode;
        };

        Number.prototype.GetHashCode = function (): number {
            const stringValue = String(this.value);
            let hashCode = 0;
            for (let i = 0; i < stringValue.length; i++) {
                const charCode = stringValue.charCodeAt(i);
                // 使用位运算符对哈希码进行计算
                hashCode = ((hashCode << 5) - hashCode) + charCode;
                hashCode |= 0; // 确保结果是一个32位有符号整数
            }
            return hashCode;
        };

    }

}